package com.engine4cloud.tdf.education.controller.web;

import com.engine4cloud.tdf.common.core.constant.SecurityConstants;
import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.data.web.response.PageInfo;
import com.engine4cloud.tdf.supervision.dto.query.SpHelpDepartQueryDTO;
import com.engine4cloud.tdf.supervision.dto.result.SpHelpResultDTO;
import com.engine4cloud.tdf.supervision.feign.RemoteHelpService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 适应性帮扶记录-web
 *
 * @author wenjie
 * @date 2024-08-15 15:06:54
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/web/help/record")
@Tag(description = "eduHelpRecord", name = "适应性帮扶记录-web")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class EduHelpRecordWebController {

    @Resource
    private final RemoteHelpService helpService;

    /**
     * 分页查询
     *
     * @param dto 适应性帮扶记录
     * @return R<PageInfo < SpHelpResultDTO>>
     */
    @Operation(summary = "分页查询", description = "分页查询")
    @GetMapping("/page")
    public R<PageInfo<SpHelpResultDTO>> pageList(@Valid @ParameterObject SpHelpDepartQueryDTO dto) {
        return helpService.getDeptPageList(dto, SecurityConstants.FROM_IN);
    }

    /**
     * 通过id查询适应性帮扶记录
     *
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}")
    public R<SpHelpResultDTO> getById(@PathVariable("id") Long id) {
        return helpService.getById(id, SecurityConstants.FROM_IN);
    }
}